<extend name="Public/user"/>
<block name="link">
	<title>包裹列表</title>
	<link href="/static/lida/css/tran_style.css" rel="stylesheet" type="text/css" />
	<link href="__CSS__/bootstrap.min.css" rel="stylesheet"/>
	<script src="__JS__/jquery.js"></script>
	<script src="__JS__/bootstrap.js"></script>
	<link href="__CSS__/bglb-style.css" rel="stylesheet"/>
	<link href="__CSS__/css.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="__CSS__/common.css">
	<script src="__JS__/jquery-1.9.1.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="__STATIC__/thinkbox/thinkbox/jquery.thinkbox.js"></script>
	<script type="text/javascript" src="__JS__/style.js"></script>
</block>
<block name="user-right">
	<style>
		/* icon- */
		.icon-edit{display: inline-block;width:16px;height:12px;background: url('__IMG__/icon-edit.png') no-repeat;background-size: 16px 12px;}
		.icon-trash{display: inline-block;width:12px;height:12px;background: url('__IMG__/icon-trash.png') no-repeat;background-size: 12px 12px;}
		.icon-eye{display: inline-block;width:18px;height:12px;background: url('__IMG__/icon-eye.png') no-repeat;background-size: 18px 12px;}
		.num{margin-left: 3px ;margin-right: 3px;color: #AB263C;}
		.current{color: #AB263C;}
	</style>
	<!--main_right-->
	<div class="main_r f_fr">
		<div class="user_kx">
			<h3 class="user_kx_title">
				{:lang('forecast_list')}

			</h3>
		</div>
		<if condition="$keyunsong eq 1">
			<div class="input-group f_fr" style="width:180px; margin-right:10px;">

			</div>
			<else />
			<div class="input-group f_fr" style="width:180px; margin-right:10px;">
				<form action="{:url('User/yubaolist','status='.$_GET['status'])}" method="post">
					<input type="text" class="form-control" name="kuaidi_sn" value="<?php echo $_GET['kuaidi_sn'] ?>" style="width: 100px;margin-top: 2px;padding: 2px;" placeholder="{:lang('ex_num')}">

					<span class="input-group-btn">
									  <input type="submit" value="搜索" class="btn btn-default" style="background:#F00; color:#FFF;height: 30px;">
								  </span>
				</form>
			</div>
		</if>
		<div class="user_kx">

			<!-- Nav tabs -->
			<ul class="nav nav-tabs" role="tablist">
				<li role="presentation" class="<eq name="status" value="">active<else /></eq>"><a href="{:url('User/yubaolist')}"  >{:lang('all')}</a></li>
				<li role="presentation" class="<eq name="status" value="1">active<else /></eq>"><a href="{:url('User/yubaolist','status=1')}"  >{:lang('on_way')}</a></li>
				<li role="presentation" class="<eq name="status" value="2">active<else /></eq>"><a href="{:url('User/yubaolist','status=2')}"  >{:lang('storage')}</a></li>
				<li role="presentation" class="<eq name="status" value="4">active<else /></eq>"><a href="{:url('User/yubaolist','status=4')}"  >{:lang('library')}</a></li>
				<li role="presentation" class="<eq name="status" value="10">active<else /></eq>"><a href="{:url('User/yubaolist','status=10')}"  >仓转记录</a></li>

			</ul>

			<!-- Tab panes -->
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane active" id="home">
					<eq name="status" value="10">

						<table class="table table-striped table-bordered">
							<tbody>
							<tr>
								<th class="w90">快递单号 </th>
								<th class="w100">信息</th>
								<th class="w80">操作时间</th>
								<th class="w60">状态</th>
							</tr>
							<if condition="$list">
								<volist name="list" id="v">
									<tr >

										<td>{$v.kuaidi_sn}</td>
										<td>{$v['msg']}</td>
										<td>{$v['finish_time']}</td>
										<td>{$v['status']}</td>

									</tr>
								</volist>
								<else />
								<tr>
									<td <if condition="$keyunsong eq 1"> colspan="11"<else /> colspan="10"</if>>{:lang('no_infos')}</td>
								</tr>
							</if>
							</tbody>
						</table>


						<else />

						<table class="table table-striped table-bordered">
							<tbody>
							<tr>
								<th class="w90">{:lang('ex_num')}</th>
								<th class="w100">{:lang('baoguo_name')}</th>
								<th class="w50">{:lang('jiazhi')}(日元)</th>
								<th class="w60">{:lang('remark')}</th>
								<th class="w60">重量(kg)</th>
								<th class="w50">{:lang('status')}</th>
								<th class="w80">{:lang('add_time')}</th>
								<th class="w80">{:lang('operation')}</th>
							</tr>
							<if condition="$list">
								<volist name="list" id="v">
									<tr >
										<if condition="$keyunsong eq 1">
											<td style="text-align: center;"><input type="checkbox" class="checkboxid" name="yubaoid[]" value="{$v.id}" <in name="v.id" value="$ybids">checked="true"</in>></td>
										</if>
										<td>{$v.kuaidi_sn}</td>
										<td>{$v['baoguo_name']? $v['baoguo_name']:''}</td>
										<td>{$v['jiazhi'] ? $v['jiazhi']:''}</td>

										<td>{$v['remark']? $v['remark']:''}</td>
										<td>{$v['weight']? $v['weight']:''}</td>
										<td>{$v.status|getyubaostatus}</td>
										<td>{$v.add_time|time_format='Y-m-d'}</td>
										<td>
											<gt name="v.yundan_id" value="0">
												<a href="{:url('User/dingdanview','id='.$v['yundan_id'])}" title="{:lang('belong_order')}"><i class="icon-eye"></i></a>
											</gt>
											<if condition="($v.status eq 1) OR (($v.yundan_id eq 0) AND ($v.status eq 2))">
												<a href="###" title="{:lang('edit')}" class="bianji" yid="{$v.id}"><i class="icon-edit"></i></a>
											</if>
											<eq name="v.status" value="1">
												<eq name="v.yundan_id" value="0">
													<a href="###" title="{:lang('delete')}" class="delete" did="{$v.id}"><i class="icon-trash"></i></a>
												</eq>
											</eq>
											<!--<if condition="($v.status eq 2 ) and ($v.yundan_id eq  0 ) ">
												<a href="###" title="仓转" class="transfer" kid="{$v.member_id}"  kdid="{$v.kuaidi_sn}" yid="{$v.id}"><i class="glyphicon glyphicon-transfer" style="color:#1D9D74" ></i></a>
											</if>-->
											<if condition="($v.czstatus eq  1 )">
												<span style="color: red;margin-left: 3px;">仓转中</span>
											</if>
										</td>
									</tr>
								</volist>
								<else />
								<tr>
									<td <if condition="$keyunsong eq 1"> colspan="11"<else /> colspan="10"</if>>{:lang('no_infos')}</td>
								</tr>
							</if>
							</tbody>
						</table>

					</eq>

					<if condition="$keyunsong eq 1">
						<div style="float: left;width: 120px;margin-top: 10px;">
							<a href="{:url('User/yubaoadd')}" class="btnqd tijiaodingdan" style="width: 100%;float: left;display:block;"	>{:lang('submit_order')}</a>
						</div>
					</if>
					<div>
						{$_page}
						</nav>
					</div>
				</div>

			</div>

		</div>

	</div>
	<div id="ybedit" style="display:none;" >
		<form action="{:url('User/yubaoedit')}" method="post" id="edityubao">
<!--
			<span style="display:inline-block;width: 80px;text-align: left;">{:lang('ex_num')}：</span><input type="text" name="kuaidi_sn" value=""> <br><br>
-->
			<span style="display:inline-block;width: 80px;text-align: left;">{:lang('baoguo_name')}：</span><input type="text" name="baoguo_name" value=""><br><br>
			<span style="display:inline-block;width: 80px;text-align: left;">{:lang('jiazhi')}(日元)：</span><input type="text" name="jiazhi" value=""><br><br>
			<span style="display:inline-block;width: 80px;text-align: left;">{:lang('remark')}：<br></span><input type="text" name="remark" value=""><br><br>
			<input type="hidden" name="id" value="">
			<div style="text-align: center;"><button>{:lang('submit')}</button></div>
		</form>
	</div>
	<div id="transfer-modal" style="display:none;" >
		<span style="display:inline-block;width: 100%;text-align: left;">请输入仓转对象的用户id：</span>
		<br>
		<label for="transferId"></label><input type="text" name="transferId" id="transferId" value="" >
		<p class='warn' style='color: red;display: none;'>该用户id不存在。</p>
		<div style="text-align: center;"><button id="transfer-do" class="thinkbox-button-ok">确定</button></div>
	</div>
	<div id="transfer-confrm" style="display:none;" >
		<form action="{:url('User/transfor')}" method="post" id="editcz">
		<span style="display:inline-block;width: 100%;text-align: left;" class="transfer-msg">
	</span>
			<input type="hidden" name="packageId" value="">
			<input type="hidden" name="currentId" value="">
			<input type="hidden" name="toId" value="">
			<input type="hidden" name="kdid" value="">
			<div style="text-align: center;"><button class="thinkbox-button-ok" >确定</button></div>
		</form>
	</div>

	</div>
</block>
<block name="javascript">
	<script type="text/javascript">

		function PrefixInteger(num, n,pre) {
			return pre+(Array(n).join(0) + num).slice(-n);
		}

		$(document).ready(function(){
			$('.bianji').click(function(){
				var id=$(this).attr('yid');
				var loading=$.thinkbox.loading('{:lang("loading")}');

				$.post("{:url('User/getyubaoinfo')}",{'id':id},function(data){

					$('input[name="kuaidi_sn"]').val(data.kuaidi_sn);
					//$('input[name="kuaidi_name"]').val(data.kuaidi_name);
					$('input[name="baoguo_name"]').val(data.baoguo_name);
					$('input[name="jiazhi"]').val(data.jiazhi);
					$('input[name="remark"]').val(data.remark);
					$('input[name="id"]').val(data.id);
					/*$('#baoguo_type').find('option[value='+data.baoguo_type+']').attr('selected',true);
					$('#baoguo_type').find('option').not('option[value='+data.baoguo_type+']').attr('selected',false);*/
					$('#is_chaibao').find('option[value='+data.is_chaibao+']').attr('selected',true);
					$('#is_chaibao').find('option').not('option[value='+data.is_chaibao+']').attr('selected',false);
					$.thinkbox('#ybedit',{'title':'Edit','dataEle':this,'drag':true});
					loading.hide();
				})
			})
			$('.transfer').click(function(){
				$(".warn").hide();//验证清除
				$('input[name="currentId"]').val('').val($(this).attr('kid'));
				$('input[name="packageId"]').val('').val($(this).attr('yid'));
				$('input[name="kdid"]').val('').val($(this).attr('kdid'));
				var loading = $.thinkbox('#transfer-modal',{'title':'仓转','width':220,'height':150,'dataEle':this,'drag':true});

			})
			//弹出框设置值
			$('#transferId').bind('keyup', function() {
				$("#transferId").val($(this).val())
			})
			$('#transfer-do').click(function(e){
				var  orderId = $('input[name="packageId"]').val();
				var  transforId = $('#transferId').val();
				$.ajax({
					type: "POST",
					url:'{:url("User/checkId")}',
					data:{"id":transforId},
					success: function(data) {
						if (data.result == 0 ) {
							$(".warn").hide();//清空验证
							$('input[name="toId"]').val('').val(data.msg.toId);
							var html = "您确认您要将快递包裹编号为【"+$('input[name="kdid"]').val()+"】的归属转移给用户【用户id："+PrefixInteger(data.msg.toId,6,"LD")+"】吗？"
							$(".transfer-msg").html(html);
							var loading = $.thinkbox('#transfer-confrm',{'title':'确认','width':220,'height':170,'dataEle':this,'drag':true});
						} else {
							$('input[name="toId"]').val('');
							$(".warn").html(data.msg).show()

						}
					}
				});

			})
			$(".field").change(function(){
				$(this).css("background-color","#FFFFCC");
			});
			$('form#edityuba').submit(function(){
				var self = $(this);
				$.post(self.attr("action"), self.serialize(), success, "json");
				return false;
				function success(data){
					if (data.status) {
						$.thinkbox.success(data.info);
						setTimeout('location.reload()',1100);
					}else{
						$.thinkbox.error(data.info);
						setTimeout('location.reload()',1100);
					};
				}
			})
			$('form#editcz').submit(function(){
				var self = $(this);
				$.post(self.attr("action"), self.serialize(), success, "json");
				return false;
				function success(data){
					setTimeout('location.reload()',700);
				}
			})
			$('.checkall').click(function(){
				var selected = $(this).is(':checked');
				$('.checkboxid').each(function(index,item){
					postItemChange(item,selected?1:0);
					$(item).prop('checked',selected);
				});

			});
			var postItemChange = function(item,isSelected){
				$.post("{:url('User/select')}", {'yubao_id':$(item).val(),'selected':isSelected}, function(data){
					if(data.status){
						$('.tijiaodingdan').show();
					}else{
						$.thinkbox.error(data.info);
					}
				});
			};
			$('.delete').click(function(){
				var id=$(this).attr('did');

				if(confirm('{:lang("confirm_delete")} ')){
					$.post("{:url('User/yubaodel')}",{'id':id},function(result){
						if (result.status) {
							$.thinkbox.success(result.info);
							setTimeout('location.reload()',1000);
						}else{
							$.thinkbox.error(result.info);
						};
					})
				}


			});

		})
	</script>
</block>